//#define __FORCE_TRACE__
//#define __FORCE_DEBUG__
//#define __FORCE_INFO__
#define THIS_FILE "SniperTraining\fn_dlgClick.sqf"
#include <core_macros.h>

TRACE_1("Start",_this);
TMFPROFILERSTART;

private ["_type_selection","_direction_selection","_distance","_lane","_click_idx","_timeOut","_params","_direction"];
DEFAULT_PARAM(_type_selection,0,0);
DEFAULT_PARAM(_direction_selection,1,0);
DEFAULT_PARAM(_distance,2,0);
DEFAULT_PARAM(_lane,3,0);

if (_type_selection < 0 || _type_selection >= (count GVAR(TRAINING_UNITS_TYPES))) exitWith {};
if (_direction_selection < 0 || _direction_selection >= (count GVAR(TRAINING_DIRECTIONS))) exitWith {};
if (_distance <= 0) exitWith {};
if (_lane <= 0) exitWith {};

_click_idx = _distance * 10 + _lane;
_timeOut = 0;
if (count GVAR(CLICK_TIMEOUT) > _click_idx) then {
	_timeOut = GVAR(CLICK_TIMEOUT) select _click_idx;
}; 
if (_timeOut > time) exitWith {hint localize "STR_ST_WAIT_BEFORE_CREATING_HERE";};

_direction = (360 / (count GVAR(TRAINING_DIRECTIONS))) * _direction_selection;

_params = [
	GVAR(TRAINING_UNITS_TYPES) select _type_selection,
	_direction,
	_distance,
	_lane
];

["CreateTarget",_params] call FUNC(callEvent);

TRACE("End");
TMFPROFILERSTOP;
